package com.yxy.system.domain.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
public class MetricDataOutDto {
    private String agentId;
    private Date collectTime;

    private String version;

    private Cpu cpu;

    @Data
    public static class Cpu {
        // CPU指标
        private BigDecimal cpuUsage;          // CPU总使用率%
        private BigDecimal cpuSystemUsage;    // CPU系统使用率%
        private BigDecimal cpuUserUsage;      // CPU用户使用率%
        private BigDecimal[] loadAverage;     // 系统负载
    }

    private Memory memory;

    @Data
    public static class Memory {
        // 内存指标
        private BigDecimal memoryTotal;         // 总内存(bytes)
        private BigDecimal memoryUsed;          // 已用内存(bytes)
        private BigDecimal memoryUsage;       // 内存使用率%
        private BigDecimal swapTotal;           // 交换内存总大小(bytes)
        private BigDecimal swapUsed;            // 交换内存已用大小(bytes)
        private BigDecimal swapUsage;         // 交换内存使用率%
    }


    // 磁盘指标
    private List<DiskMetricDto> disks;
    private BigDecimal inodeUsage;        // inode使用率

    private Io io;
    // IO指标
    @Data
    public static class Io {
        private Long ioReadBytes;         // IO总读取字节大小
        private Long ioWriteBytes;        // IO总写入字节大小
        private Long ioReads;             // IO总读取次数
        private Long ioWrites;            // IO总写入次数
        private BigDecimal ioReadBytesRate;   // IO每秒读取字节大小
        private BigDecimal ioWriteBytesRate;  // IO每秒写入字节大小
        private BigDecimal ioReadsRate;       // IO每秒读取次数
        private BigDecimal ioWritesRate;      // IO每秒写入次数
    }

    // 网络指标
    private NetworkMetric network;

    private  Connections connections;

    @Data
    public static class Connections{
        // 连接数指标
        private Integer tcpConnections;   // TCP连接数
        private Integer udpConnections;   // UDP连接数
        private Integer inetConnections;  // INET连接数
        private Integer totalConnections; // 总连接数
    }

    // 系统信息
    private SystemInfo system;

    @Data
    public static class DiskMetricDto {
        private String mountPoint;
        private String deviceName;
        private BigDecimal total;
        private BigDecimal used;
        private BigDecimal usage;
        private Long inodesTotal;     // inode总数
        private Long inodesUsed;      // 已用inode数
        private BigDecimal inodeUsage;    // inode使用率%
    }

    @Data
    public static class NetworkMetric {
        private Long bytesSent;           // 总发送字节
        private Long bytesRecv;           // 总接收字节
        private Long packetsSent;         // 总发送包数量
        private Long packetsRecv;         // 总接收包数量
        private BigDecimal sendRate;          // 每秒发送字节
        private BigDecimal receiveRate;       // 每秒接收字节
        private BigDecimal sendPacketsRate;   // 每秒发送包数量
        private BigDecimal receivePacketsRate;// 每秒接收包数量
    }

    @Data
    public static class SystemInfo {
        private String hostname;
        private String os;
        private String cpuModel;
        private Integer cpuCores;
        private Integer cpuThreads;
        private BigDecimal cpuFrequency;
        private BigDecimal memorySize;
        private BigDecimal diskSize;
        private BigDecimal networkBandwidthUp;   // 上行带宽 Mbps
        private BigDecimal networkBandwidthDown; // 下行带宽 Mbps
        private Integer processCount;
        private Long uptime;
    }
}
